crash_hackingfandomcom-20200215-history
Subsystem
A subsystem is a self-contained system within a larger system. In each of the Crash games, there exist a number of different subsystems. Each subsystem handles a different aspect of the game's function. Many of these subsystems are associated with the type of entry that they primarily operate upon. In fact, an entry's type is just the ID of the subsystem that operates upon its data; thus, both terms entry type and subsystem ID are inclusively interchangeable with subsystem type. Subsystem Table Each of the Crash games has a subsystem table. Each entry in the subsystem table contains a 4 character acronym or identifier string, and a number of callback functions specific to the subsystem with that identifier. Location The subsystem table is located at the following addresses in each of the Crash games: * Crash 1 - 0x514DC Structure The subsystem table has the following structure in each of the Crash games, with the exception that Crash 2 (and 3?) omit the last callback, (*deinit)(): struct subsystem { char name4; unsigned long pad; void (*init)(); void (*postinit)(); void (*onload)(entry*); void (*onfree)(entry*); void (*deinit)(); } subsystemsNS_COUNT_SUBSYSTEMS; Subsystem name Each subsystem specifies a 4 character acronym as its name. See below for a list of the subsystem names in each game. Callbacks Each entry in the subsystem table may or may not specify the following callbacks: * init - Called during subsystem initialization to initialize this subsystem * postinit - Called during subsystem initialization after... * onload - Called after an entry of this subsystem type is paged into memory * onfree - Called after an entry of this subsystem type is loaded out of memory * deinit - Called during subsystem deinitialization (Crash 1 only) The init and postinit callbacks of each subsystem are called during Paging and Subsystem Initialization; each of these callbacks refers to a routine that initializes its associated subsystem. ... All together, a subsystem's callbacks simulate 5 polymorphic functions that would otherwise override a subsystem base class's virtual functions of the same name. Subsystem names Crash 1 There are a total of 21 subsystems in Crash 1. Note that entries of type 0 do not exist. For this reason, the first subsystem has the name NONE. Bolded entries in the table indicate that (while the subsystem exists) there do not exist entries of that subsystem type in any NSF file. Crash 2 There are a total of 22 subsystems in Crash 2. Note that entries of type 0 do not exist. For this reason, the first subsystem has the name NONE. Bolded entries in the table indicate that (while the subsystem exists) there do not exist entries of that subsystem type in any NSF file. Note: LDAT entries for each level are mentioned in the NSD, meaning they were in the NSF at some point. Crash 3 There are a total of 22 subsystems in Crash 3. Note that entries of type 0 do not exist. For this reason, the first subsystem has the name NONE. Bolded entries in the table indicate that (while the subsystem exists) there do not exist entries of that subsystem type in any NSF file. Note: LDAT entries for each level are mentioned in the NSD, meaning they were in the NSF at some point.